package com.zego.wawaji.ui.play.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.zego.wawaji.base.data.BaseData;
import com.zego.wawaji.base.utils.StringUtils;

import org.json.JSONObject;

/**
 * 抓中者
 * Created by Su on 2017/12/8.
 */
public class LuckyUser extends BaseData implements Parcelable {
    private String userHead;
    private String userName;
    private String creatTime;   // 记录插入时间，作为对应用户获取时间

    @Override
    public void parseJson(String jsonStr) {
        JSONObject jsonObject = getJsonObject(jsonStr);

        this.setUserHead(jsonObject.optString("Avatar"));
        this.setUserName(jsonObject.optString("NickName"));
        this.setCreatTime(StringUtils.getCreateTime(jsonObject.optString("CreateTime")));
    }

    public String getUserHead() {
        return userHead;
    }

    public void setUserHead(String userHead) {
        this.userHead = userHead;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getCreatTime() {
        return creatTime;
    }

    public void setCreatTime(String creatTime) {
        this.creatTime = creatTime;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.userHead);
        dest.writeString(this.userName);
        dest.writeString(this.creatTime);
    }

    public LuckyUser() {
    }

    protected LuckyUser(Parcel in) {
        this.userHead = in.readString();
        this.userName = in.readString();
        this.creatTime = in.readString();
    }

    public static final Creator<LuckyUser> CREATOR = new Creator<LuckyUser>() {
        @Override
        public LuckyUser createFromParcel(Parcel source) {
            return new LuckyUser(source);
        }

        @Override
        public LuckyUser[] newArray(int size) {
            return new LuckyUser[size];
        }
    };
}
